﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Runtime.InteropServices;

    public class SymbolShow
    {
        private readonly Chain.IDAL.SymbolShow dal = new Chain.IDAL.SymbolShow();

        public int Add(Chain.Model.SymbolShow model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.SymbolShow> DataTableToList(DataTable dt)
        {
            List<Chain.Model.SymbolShow> list = new List<Chain.Model.SymbolShow>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.SymbolShow item = new Chain.Model.SymbolShow();
                    if ((dt.Rows[i]["SymbolID"] != null) && (dt.Rows[i]["SymbolID"].ToString() != ""))
                    {
                        item.SymbolID = int.Parse(dt.Rows[i]["SymbolID"].ToString());
                    }
                    if ((dt.Rows[i]["SymbolTitle"] != null) && (dt.Rows[i]["SymbolTitle"].ToString() != ""))
                    {
                        item.SymbolTitle = dt.Rows[i]["SymbolTitle"].ToString();
                    }
                    if ((dt.Rows[i]["SymbolPhoto"] != null) && (dt.Rows[i]["SymbolPhoto"].ToString() != ""))
                    {
                        item.SymbolPhoto = dt.Rows[i]["SymbolPhoto"].ToString();
                    }
                    if ((dt.Rows[i]["SymbolDesc"] != null) && (dt.Rows[i]["SymbolDesc"].ToString() != ""))
                    {
                        item.SymbolDesc = dt.Rows[i]["SymbolDesc"].ToString();
                    }
                    if ((dt.Rows[i]["SymbolTime"] != null) && (dt.Rows[i]["SymbolTime"].ToString() != ""))
                    {
                        item.SymbolTime = DateTime.Parse(dt.Rows[i]["SymbolTime"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int SymbolID)
        {
            return this.dal.Delete(SymbolID);
        }

        public bool DeleteList(string SymbolIDlist)
        {
            return this.dal.DeleteList(SymbolIDlist);
        }

        public bool Exists(int SymbolID)
        {
            return this.dal.Exists(SymbolID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public Chain.Model.SymbolShow GetModel(int SymbolID)
        {
            return this.dal.GetModel(SymbolID);
        }

        public List<Chain.Model.SymbolShow> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public DataSet GetSymbolShowInfo(int PageSize, int PageIndex, out int resCount, params string[] strWhere)
        {
            return this.dal.GetSymbolShowInfo(PageSize, PageIndex, out resCount, strWhere);
        }

        public bool Update(Chain.Model.SymbolShow model)
        {
            return this.dal.Update(model);
        }
    }
}

